package cn.fy.erupt.model.work;

import javax.persistence.*;
import xyz.erupt.annotation.*;
import xyz.erupt.annotation.sub_erupt.*;
import xyz.erupt.annotation.sub_field.*;
import xyz.erupt.annotation.sub_field.sub_edit.*;
import xyz.erupt.upms.helper.HyperModelVo;
import xyz.erupt.upms.model.base.HyperModel;
import xyz.erupt.jpa.model.BaseModel;
import java.util.Set;
import java.util.Date;

@Erupt(name = "工作周报")
@Table(name = "t_work_weekly")
@Entity
public class Weekly extends HyperModelVo {

        @EruptField(
                views = @View(
                        title = "周", sortable = true
                ),
                edit = @Edit(
                        title = "周",
                        type = EditType.DATE, search = @Search, notNull = true,
                        dateType = @DateType(type = DateType.Type.WEEK)
                )
        )
        private String weekNo;

        @EruptField(
                views = @View(
                        title = "开始日期"
                ),
                edit = @Edit(
                        title = "开始日期",
                        type = EditType.DATE, search = @Search(vague = true), notNull = true,
                        dateType = @DateType
                )
        )
        private Date startDate;

        @EruptField(
                views = @View(
                        title = "结束日期"
                ),
                edit = @Edit(
                        title = "结束日期",
                        type = EditType.DATE, search = @Search(vague = true), notNull = true,
                        dateType = @DateType
                )
        )
        private Date endDate;

        @EruptField(
                views = @View(
                        title = "备注",
                        width = "200px"
                ),
                edit = @Edit(
                        title = "备注",
                        type = EditType.TEXTAREA
                )
        )
        private @Lob String remark;

        @EruptField(
                views = @View(
                        title = "工作周报项"
                ),
                edit = @Edit(
                        title = "工作周报项",
                        type = EditType.TAB_TABLE_ADD
                )
        )
        @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
        @OrderBy
        @JoinColumn(name = "weekly_id") 
        private Set<WeeklyItem> weeklyItem;

}

